package cn.yunbamboos.rest.service.dto.in;

import cn.yunbamboos.helper.JSONHelper;
import cn.yunbamboos.rest.service.dto.DTO;
import cn.yunbamboos.rest.service.session.SessionHelper;
import com.alibaba.fastjson2.JSONObject;
import jakarta.servlet.http.HttpServletRequest;

public abstract class BaseInDTO extends SessionHelper implements DTO, JSONHelper {

    private boolean setRequestMethodCalled;
    private HttpServletRequest request;

    public void decode(JSONObject json) {

    }

    public void setRequest(HttpServletRequest request) {
        if (setRequestMethodCalled) {
            throw new IllegalStateException("setRequest() method can only be called once.");
        }
        setRequestMethodCalled = true;
        this.request = request;
    }

    public String getHeader(String key) {
        return request.getHeader(key);
    }

}
